package com.wzdigit.wms.basic.enums.operate;


import com.wzdigit.wms.basic.enums.BaseEnum;

import java.util.*;

/**
 * 单据操作代码枚举类
 * @author yangwenbiao
 *
 */
public enum OperateCodeEnum implements BaseEnum {

	/**
	 * WhsType
	 * 单据操作代码
	 */
	CREATE(1, "create", "新建"),
	CANCEL(2, "cancel", "取消"),
	REJECT(3, "reject", "作废"),
	APPROVE(4, "approve", "审核"),
	CLOSED(5, "closed", "关闭");

	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 */
	public String description;

	OperateCodeEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	OperateCodeEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static OperateCodeEnum getEnumByCode(int enumCode) {
		OperateCodeEnum[] values = OperateCodeEnum.values();
		OperateCodeEnum samplingEnum = null;

		for (OperateCodeEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static OperateCodeEnum getEnumByName(String enumName) {
		OperateCodeEnum[] values = OperateCodeEnum.values();
		OperateCodeEnum repairEnum = null;

		for (OperateCodeEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<Integer, String>();
		OperateCodeEnum[] values = OperateCodeEnum.values();
		for (OperateCodeEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}
	
	public static List<Map<String, Object>> getEnumListByDescription(String enumDescription) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		OperateCodeEnum[] values = OperateCodeEnum.values();
		for (OperateCodeEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				Map<String, Object> enumMap = new HashMap<String, Object>(2);
				enumMap.put("code", value.getCode());
				enumMap.put("name", value.getEnumName());
				list.add(enumMap);
			}
		}
		return list;
	}
}
